package com.echovin.esb.gateway.mapper;

import com.echovin.esb.gateway.model.GatewayServerGroup;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface GatewayServiceGroupMapper {
    @Select("select * from GATEWAY_SERVICE_GROUP")
    List<GatewayServerGroup> getGatewayServiceGroup();

    @SelectKey(keyProperty = "record.id", resultType = String.class, before = true,
            statement = "select replace(uuid(), '-', '')")
    @Options(keyProperty = "record.id", useGeneratedKeys = true)
    @Insert("insert into GATEWAY_SERVICE_GROUP(ID,GROUP_NAME,REMARK,CREATER,CREATE_TIME) " +
            "values(#{record.id},#{record.groupName},#{record.remark},#{record.creater},#{record.createTime})")
    int insert(@Param("record") GatewayServerGroup record);

    @Update("update GATEWAY_SERVICE_GROUP set IS_DELETE = 1, UPDATER = #{record.updater}, UPDATE_TIME = #{record.updateTime} where ID = #{record.id}")
    int delete(GatewayServerGroup record);

    @Update("update GATEWAY_SERVICE_GROUP set GROUP_NAME = #{record.groupName}, REMARK = #{record.remark}, UPDATER = #{record.updater}, UPDATE_TIME = #{record.updateTime} where ID = #{record.id}")
    int update(GatewayServerGroup record);

}
